﻿<!-- License
// Copyright © 2014 Łukasz Świątkowski
// http://www.lukesw.net/
//
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library.  If not, see<http://www.gnu.org/licenses/> .
-->

<Window x:Class="Luminous.Windows.TaskDialogWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:ctrl="clr-namespace:Luminous.Windows.Controls"
        xmlns:conv="clr-namespace:Luminous.Windows.Converters"
        x:ClassModifier="internal" Loaded="Window_Loaded" 
        Title="TaskDialogWindow" MinWidth="300" SizeToContent="WidthAndHeight" SnapsToDevicePixels="True" TextOptions.TextFormattingMode="Display"
        WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow" ResizeMode="NoResize" Background="#FFFFFF">

    <Window.Resources>
        <Style x:Key="MainInstructionStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="Margin" Value="9,11,9,-2" />
            <Setter Property="FontSize" Value="12pt" />
            <Setter Property="LineHeight" Value="12pt" />
            <Setter Property="Foreground" Value="#003399" />
            <!--Setter Property="MaxWidth">
                <Setter.Value>
                    <Binding Path="Content">
                        <Binding.Converter>
                            <local:ContentToMaxWidthConverter/>
                        </Binding.Converter>
                    </Binding>
                </Setter.Value>
            </Setter-->
        </Style>
        <Style x:Key="ContentStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="TextWrapping" Value="Wrap" />
            <Setter Property="LineHeight" Value="{Binding Path=FontSize}" />
            <Setter Property="Foreground" Value="#000000" />
        </Style>
        <Style TargetType="{x:Type Hyperlink}" BasedOn="{StaticResource {x:Type Hyperlink}}">
            <Setter Property="Foreground" Value="#0066CC" />
            <Setter Property="TextDecorations" Value="{x:Null}" />
            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Foreground" Value="#3399FF" />
                    <Setter Property="TextDecorations" Value="Underline" />
                </Trigger>
            </Style.Triggers>
        </Style>
        <LinearGradientBrush x:Key="GradientNormal" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Offset="0" Color="#FFFFFF" />
            <GradientStop Offset="1" Color="#FFFFFF" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GradientSecuritySuccess" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Offset="0" Color="#157615" />
            <GradientStop Offset="1" Color="#39963F" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GradientSecurityQuestion" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Offset="0" Color="#00B1F2" />
            <GradientStop Offset="1" Color="#48CDFE" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GradientSecurityWarning" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Offset="0" Color="#F2B100" />
            <GradientStop Offset="1" Color="#FECD48" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GradientSecurityError" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Offset="0" Color="#AC0100" />
            <GradientStop Offset="1" Color="#E30100" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GradientSecurityShieldBlue" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Offset="0" Color="#045082" />
            <GradientStop Offset="1" Color="#1C8185" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GradientSecurityShieldGray" StartPoint="0,0.5" EndPoint="1,0.5">
            <GradientStop Offset="0" Color="#9D8F85" />
            <GradientStop Offset="1" Color="#A49890" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="ProgressBarNormal" StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Offset="0" Color="#CDFFCD" />
            <GradientStop Offset="0.35" Color="#8BFF8B" />
            <GradientStop Offset="0.35" Color="#00D200" />
            <GradientStop Offset="0.65" Color="#00D200" />
            <GradientStop Offset="1" Color="#00FF00" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="ProgressBarPause" StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Offset="0" Color="#FFFFCD" />
            <GradientStop Offset="0.35" Color="#FFFF8B" />
            <GradientStop Offset="0.35" Color="#D2D200" />
            <GradientStop Offset="0.65" Color="#D2D200" />
            <GradientStop Offset="1" Color="#FFFF00" />
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="ProgressBarError" StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Offset="0" Color="#FFCDCD" />
            <GradientStop Offset="0.35" Color="#FF8B8B" />
            <GradientStop Offset="0.35" Color="#D20000" />
            <GradientStop Offset="0.65" Color="#D20000" />
            <GradientStop Offset="1" Color="#FF0000" />
        </LinearGradientBrush>
    </Window.Resources>

    <Grid>
        <Grid.LayoutTransform>
            <ScaleTransform x:Name="CustomScale" />
        </Grid.LayoutTransform>
        <Grid.RowDefinitions>
            <!-- Main instruction -->
            <RowDefinition Height="Auto" />
            <!-- Content -->
            <RowDefinition Height="Auto" />
            <!-- Expanded info -->
            <RowDefinition Height="Auto" />
            <!-- Progress bar -->
            <RowDefinition Height="Auto" />
            <!-- Radio buttons -->
            <RowDefinition Height="Auto" />
            <!-- Custom content -->
            <RowDefinition Height="Auto" />
            <!-- Command links -->
            <RowDefinition Height="Auto" />
            <!-- Buttons -->
            <RowDefinition Height="Auto" />
            <!-- Footer -->
            <RowDefinition Height="Auto" />
            <!-- Expanded footer info -->
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <!-- Icon -->
            <ColumnDefinition Width="Auto" />
            <!-- Content -->
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <!-- Gradient -->
        <Border Name="BorderGradient" Grid.ColumnSpan="2" Visibility="Collapsed" />

        <!-- Icon -->
        <Image Name="ImageMainIcon" Margin="7,7,0,7" Source="TaskDialog/Resources/Error.png" VerticalAlignment="Top" Visibility="Collapsed" />

        <!-- Main instruction -->
        <TextBlock Name="LabelMainInstruction" Grid.Column="1" Style="{DynamicResource MainInstructionStyle}" HorizontalAlignment="Left" Visibility="Collapsed" />

        <!-- Content -->
        <TextBlock Name="LabelContent" Grid.Column="1" Grid.Row="1" Margin="9,9,9,9" Style="{DynamicResource ContentStyle}" Visibility="Collapsed" />

        <!-- Expanded info -->
        <TextBlock Name="LabelExpandedInfo" Grid.Column="1" Grid.Row="2" Margin="9,0,9,9" Style="{DynamicResource ContentStyle}" Visibility="Collapsed" />

        <!-- Progressbar -->
        <ProgressBar Name="ProgressBar" Grid.Column="1" Grid.Row="3" MinWidth="355" Height="15" Margin="9,0,9,9" Visibility="Collapsed" />

        <!-- Radio buttons -->
        <StackPanel Name="PanelRadioButtons" Grid.Column="1" Grid.Row="4" Margin="9,0,9,2" Visibility="Collapsed">
            <StackPanel.Resources>
                <Style TargetType="{x:Type RadioButton}" BasedOn="{StaticResource {x:Type RadioButton}}">
                    <Setter Property="Margin" Value="9,0,9,7" />
                    <Setter Property="HorizontalAlignment" Value="Left" />
                </Style>
            </StackPanel.Resources>
        </StackPanel>

        <!-- Custom content -->
        <Grid Name="PanelCustomContent" Grid.Column="1" Grid.Row="5" Margin="9,0,9,9" Visibility="Collapsed" />

        <!-- Command links -->
        <StackPanel Name="PanelCommandLinks" Grid.Column="1" Grid.Row="6" Margin="9,6,9,9" Visibility="Collapsed" />

        <!-- Buttons -->
        <StackPanel Name="PanelButtons" Grid.Row="7" Grid.ColumnSpan="2" Margin="0,6,0,0"  Background="#F0F0F0"
                    Validation.ErrorTemplate="{x:Null}">
            <StackPanel.Visibility>
                <MultiBinding Mode="OneWayToSource">
                    <MultiBinding.Converter>
                        <conv:VisibilityMultiValueConverter/>
                    </MultiBinding.Converter>
                    <Binding Path="Expander.Visibility" />
                    <Binding Path="CheckBoxVerification.Visibility" />
                    <Binding Path="PanelRightButtons.Visibility" />
                </MultiBinding>
            </StackPanel.Visibility>
            <Border Background="#F0F0F0" BorderThickness="0,1,0,0" BorderBrush="#DFDFDF" />
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="9" />
                </Grid.RowDefinitions>
                <Expander x:Name="Expander" Margin="9,9,9,0" HorizontalAlignment="Left" Visibility="Collapsed" Expanded="Expander_Expanded" Collapsed="Expander_Collapsed">
                    <Expander.Header>
                        <Grid>
                            <TextBlock x:Name="TextBlockExpanderCollapsed" Text="Fewer details" Visibility="Visible" />
                            <TextBlock x:Name="TextBlockExpanderExpanded" Text="More details"  Visibility="Hidden" />
                        </Grid>
                    </Expander.Header>
                </Expander>
                <CheckBox x:Name="CheckBoxVerification" Grid.Row="1" Margin="14,9,9,0" Padding="7,0,0,0" HorizontalAlignment="Left" Visibility="Collapsed" />
                <WrapPanel x:Name="PanelRightButtons" Grid.Column="1" Grid.RowSpan="2" Margin="0,3,9,0" HorizontalAlignment="Right" VerticalAlignment="Top" Orientation="Horizontal" Visibility="Collapsed">
                    <WrapPanel.Resources>
                        <Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
                            <!--Setter Property="MinWidth">
                                <Setter.Value>
                                    <MultiBinding>
                                        <MultiBinding.Converter>
                                            <c:TaskDialogAndActualWidthToMinWidthMultiValueConverter />
                                        </MultiBinding.Converter>
                                        <Binding Path="ActualWidth"/>
                                        <Binding Path="." />
                                    </MultiBinding>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="MinHeight">
                                <Setter.Value>
                                    <Binding Path=".">
                                        <Binding.Converter>
                                            <c:TaskDialogToMinHeightValueConverter />
                                        </Binding.Converter>
                                    </Binding>
                                </Setter.Value>
                            </Setter-->
                            <Setter Property="Padding" Value="10,0,10,0" />
                            <Setter Property="Margin" Value="6,6,0,0" />
                        </Style>
                    </WrapPanel.Resources>
                </WrapPanel>
            </Grid>
        </StackPanel>

        <!-- Footer -->
        <StackPanel Name="PanelFooter" Grid.Row="8" Grid.ColumnSpan="2" Background="#F0F0F0" Visibility="Collapsed">
            <Border BorderThickness="0,1,0,0" BorderBrush="#DFDFDF" />
            <Border BorderThickness="0,1,0,0" BorderBrush="#FFFFFF" />
            <StackPanel Orientation="Horizontal">
                <Image Name="ImageFooterIcon" Margin="9,9,0,0" Source="TaskDialog/Resources/SmallError.png" VerticalAlignment="Top" Visibility="Collapsed" />
                <TextBlock Name="LabelFooter" Grid.ColumnSpan="2" Grid.Row="8" Margin="9,9,9,9" Style="{DynamicResource ContentStyle}" />
            </StackPanel>
        </StackPanel>

        <!-- Fotter expanded info -->
        <StackPanel Name="PanelFooterExpandedInfo" Grid.Row="9" Grid.ColumnSpan="2" Background="#F0F0F0" Visibility="Collapsed">
            <Border Background="#F0F0F0" BorderThickness="0,1,0,0" BorderBrush="#DFDFDF" />
            <Border Background="#F0F0F0" BorderThickness="0,1,0,0" BorderBrush="#FFFFFF" />
            <TextBlock Name="LabelExpandedFooterInfo" Margin="9,9,9,9" Style="{DynamicResource ContentStyle}" />
        </StackPanel>

    </Grid>
</Window>
